package com.community.util;

import org.junit.Before;
import org.junit.Test;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class ByteUtil {

    public static Byte parseByte(String str){
        try {
            return Byte.parseByte(str);
        } catch (NumberFormatException e) {
            return null;
        }
    }

    public static Integer parseInteger(String str){
        try {
            return Integer.parseInt(str);
        } catch (NumberFormatException e) {
            return null;
        }
    }
    public static Float parseFloat(String str){
        try {
            return Float.parseFloat(str);
        } catch (NumberFormatException e) {
            return null;
        }
    }

   @Test
    public void main() {
        String name = "asdab.adb@2x.png";
        name.contains("");
        Set set =  StringUtils.commaDelimitedListToSet("");
        set.add(null);

        /*String name = "asdab.adb@2x.png".replaceAll("@\\dx.",".");

        Double bill = (173/60+1)*19/100.0;
        System.out.println(bill);*/
        /*String textStyleName = "textStyleName_text";
        if(textStyleName.endsWith("_text")){
            textStyleName = textStyleName.substring(0,textStyleName.lastIndexOf("_text"));
        }*/
        System.out.println(name);
    }


    @Before
    public void test() {
        List<String> one = new ArrayList<>();
        one.forEach(ByteUtil::parseInteger);
    }

    public static String parseString(Object o){
        if(o == null){
            return "";
        }else {
            return o.toString();
        }
    }

}
